<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增工地安全质量费用')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-schedule-add"  th:object="${pId}">
            <div class="form-group" hidden>
                <div class="col-sm-8" >
                    <input name="pId" class="form-control" th:value="${pId}">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">费用名称：</label>
                <div class="col-sm-8">
                    <input id="sFeeName" name="sFeeName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">费用金额：</label>
                <div class="col-sm-8">
                    <input id="sFeeMoney" name="sFeeMoney" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">上传图片：</label>
                <div class="col-sm-8">
                    <input id="filePath" name="sUploading" class="form-control" type="file" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">备注：</label>
                <div class="col-sm-8">
                    <input id="sRemark" name="sRemark" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label" hidden>项目信息：</label>
                <div class="col-sm-8">
                    <input id="pId" name="pId" class="form-control" type="hidden" th:value="${pId}">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "ruoyi/schedule"
        $("#form-schedule-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                uploadFile();
            }
        }

        function uploadFile() {
            var formData = new FormData();
            if ($('#filePath')[0].files[0] == null) {
                $.modal.alertWarning("请先选择文件路径");
                return false;
            }
            formData.append('sFeeName', $("#sFeeName").val());
            formData.append('sFeeMoney', $("#sFeeMoney").val());
            formData.append('sRemark', $("#sRemark").val());
            formData.append('sTheHeir', $("#sTheHeir").val());
            formData.append('sTime', $("#sTime").val());
            formData.append('pId', $("#pId").val());
            formData.append('file', $('#filePath')[0].files[0]);
            $.ajax({
                url: prefix + "/add/",
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function(result) {
                    $.operate.successCallback(result);
                }
            });
        }

        $("input[name='sTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>